﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 优惠券模板表
/// </summary>
[Table("CouponTemplate")]
[Index("TemplateCode", Name = "CouponTemplate_TemplateCode_idx", IsUnique = true)]
public partial class CouponTemplate
{
    /// <summary>
    /// 优惠券模板ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 优惠券模板编号
    /// </summary>
    [StringLength(32)]
    public string TemplateCode { get; set; } = null!;

    /// <summary>
    /// 优惠券名称
    /// </summary>
    [StringLength(64)]
    public string Name { get; set; } = null!;

    /// <summary>
    /// 方案类型：0=非消费券，1=消费者承担服务费，2=商家承担服务费
    /// </summary>
    public int? SchemeType { get; set; }

    /// <summary>
    /// 优惠券类型：1=减免券，2=折扣券，3=礼品券
    /// </summary>
    public int CouponType { get; set; }

    /// <summary>
    /// 优惠金额
    /// </summary>
    public long? DiscountAmount { get; set; }

    /// <summary>
    /// 优惠折扣
    /// </summary>
    public decimal? Discount { get; set; }

    /// <summary>
    /// 使用门槛金额
    /// </summary>
    public long? UseThresholdAmount { get; set; }

    /// <summary>
    /// 平台服务费率（3%-5%）
    /// </summary>
    public decimal? PlatformServiceFeeRate { get; set; }

    /// <summary>
    /// 领取开始时间（用户可领取该优惠券的起始时间）
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime ReceiveStartTime { get; set; }

    /// <summary>
    /// 领取结束时间（用户可领取该优惠券的截止时间，超出则无法领取）
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime ReceiveEndTime { get; set; }

    /// <summary>
    /// 有效期类型：1=固定时间范围（所有券统一可用时间），2=领取后N小时内可用
    /// </summary>
    public int ValidityType { get; set; }

    /// <summary>
    /// 固定有效期的开始时间（当ValidityType=1时必填）
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? ValidityStartTime { get; set; }

    /// <summary>
    /// 固定有效期的结束时间（当ValidityType=1时必填）
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? ValidityEndTime { get; set; }

    /// <summary>
    /// 有效期时长（ValidityType=2时必填，单位：小时）
    /// </summary>
    public int? ValidityDuration { get; set; }

    /// <summary>
    /// 生效延迟类型：0=领取后立即生效，1=次日0点生效，2=领取后N小时生效
    /// </summary>
    public int EffectiveDelayType { get; set; }

    /// <summary>
    /// 生效延迟值（当EffectiveDelayType=2时必填，单位：小时）
    /// </summary>
    public int? EffectiveDelayValue { get; set; }

    /// <summary>
    /// 使用频率限制：1=无限制，2=每日，3=每周
    /// </summary>
    public int UseFrequencyType { get; set; }

    /// <summary>
    /// 每个周期内最大使用次数（如每日限用1次则填1）
    /// </summary>
    public int UseFrequencyLimit { get; set; }

    /// <summary>
    /// 总数量
    /// </summary>
    public int Total { get; set; }

    /// <summary>
    /// 已使用数量
    /// </summary>
    public int UsedCount { get; set; }

    /// <summary>
    /// 每人最多领取数量
    /// </summary>
    public int MaxIssuePerUser { get; set; }

    /// <summary>
    /// 所属商户ID
    /// </summary>
    [StringLength(32)]
    public string MerchantId { get; set; } = null!;

    /// <summary>
    /// 所属门店ID
    /// </summary>
    [StringLength(32)]
    public string? StoreId { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    public string? ExtraProperties { get; set; }

    /// <summary>
    /// 并发控制标记
    /// </summary>
    [StringLength(40)]
    public string? ConcurrencyStamp { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 创建人ID
    /// </summary>
    [StringLength(32)]
    public string? CreatorId { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? LastModificationTime { get; set; }

    /// <summary>
    /// 最后修改人ID
    /// </summary>
    [StringLength(32)]
    public string? LastModifierId { get; set; }

    /// <summary>
    /// 是否删除
    /// </summary>
    public bool IsDeleted { get; set; }

    /// <summary>
    /// 删除人ID
    /// </summary>
    [StringLength(32)]
    public string? DeleterId { get; set; }

    /// <summary>
    /// 删除时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? DeletionTime { get; set; }

    /// <summary>
    /// 模板启用状态：0=禁用,1=启用
    /// </summary>
    public int EnableStatus { get; set; }

    /// <summary>
    /// 所属收款码ID
    /// </summary>
    [StringLength(32)]
    public string? CodeId { get; set; }

    /// <summary>
    /// 海报地址
    /// </summary>
    [StringLength(255)]
    public string? PosterUrl { get; set; }

    /// <summary>
    /// 发放数量
    /// </summary>
    public int? QuantityIssued { get; set; }

    /// <summary>
    /// 是否参与推送
    /// </summary>
    public bool? IsPush { get; set; }
}
